package com.neulogistics.core.substation.api.application.converter;

import cn.hutool.json.JSONUtil;

import com.neulogistics.core.substation.api.application.query.SubstationQuery;
import com.neulogistics.core.substation.infrastructure.persistence.orm.po.SubstationPO;
import org.springframework.beans.BeanUtils;

public class SubstationQueryPOConverter {
    public static SubstationPO queryToPO(SubstationQuery substationQuery){
        if(substationQuery == null){
            return null;
        }

        SubstationPO substationPO = new SubstationPO();

        BeanUtils.copyProperties(substationQuery, substationPO);
        if(substationQuery.getSubstationAddress() != null)
            substationPO.setSubstationAddress(JSONUtil.parseObj(substationQuery.getSubstationAddress()));

        return substationPO;
    }
}
